/**
 @file ctc_register_frz.h

 @author  Copyright (C) 2011 Centec Networks Inc.  All rights reserved.

 @date 2011-7-26

 @version v2.0

   This file contains all register related data structure, enum, macro and proto.
*/

#ifndef _CTC_REGISTER_FRZ_H
#define _CTC_REGISTER_FRZ_H
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/
#include "ctc_const.h"
#include "ctc_parser.h"

/****************************************************************
*
* Defines and Macros
*
****************************************************************/

#define CTC_LB_HASH_UDF_BYTE_NUM  16
#define CTC_LB_HASH_OFFSET_DISABLE      0xFFFF

enum ctc_lb_hash_select_e
{
    CTC_LB_HASH_SELECT_L2,                        /**< [TM.TMM] Template T0, use layer2 as key */

    CTC_LB_HASH_SELECT_IPV4,                      /**< [TM.TMM] Template T4, ipv4 format, use layer3 as key */
    CTC_LB_HASH_SELECT_IPV4_TCP_UDP,              /**< [TM.TMM] Template T4, ipv4(tcp/udp) format, use layer3 as key */
    CTC_LB_HASH_SELECT_IPV4_TCP_UDP_PORTS_EQUAL,  /**< [TM.TMM] Template T4, ipv4(tcp/udp ports equal) format, use layer3 as key */
    CTC_LB_HASH_SELECT_IPV4_VXLAN,                /**< [TM.TMM] Template T4, ipv4 vxlan format, use layer3 as key */
    CTC_LB_HASH_SELECT_IPV4_GRE,                  /**< [TM.TMM] Template T5, ipv4 gre format, use layer3/4 as key */
    CTC_LB_HASH_SELECT_IPV4_NVGRE,                /**< [TM.TMM] Template T5, ipv4 nvgre format, use layer3/4 as key */

    CTC_LB_HASH_SELECT_IPV6,                      /**< [TM.TMM] Template T4, ipv6 format, use layer3 as key */
    CTC_LB_HASH_SELECT_IPV6_TCP_UDP,              /**< [TM.TMM] Template T4, ipv6(tcp/udp) format, use layer3 as key */
    CTC_LB_HASH_SELECT_IPV6_TCP_UDP_PORTS_EQUAL,  /**< [TM.TMM] Template T4, ipv6(tcp/udp ports equal) format, use layer3 as key */
    CTC_LB_HASH_SELECT_IPV6_VXLAN,                /**< [TM.TMM] Template T4, ipv6 vxlan format, use layer3 as key */
    CTC_LB_HASH_SELECT_IPV6_GRE,                  /**< [TM.TMM] Template T5, ipv6 gre format, use layer3/4 as key */
    CTC_LB_HASH_SELECT_IPV6_NVGRE,                /**< [TM.TMM] Template T5, ipv6 nvgre format, use layer3/4 as key */

    CTC_LB_HASH_SELECT_NVGRE_INNER_L2,            /**< [TM.TMM] Template T0, nvgre format, decap use layer2 as key */
    CTC_LB_HASH_SELECT_NVGRE_INNER_IPV4,          /**< [TM.TMM] Template T4, nvgre(inner ipv4) format, decap use layer3 as key */
    CTC_LB_HASH_SELECT_NVGRE_INNER_IPV6,          /**< [TM.TMM] Template T4, nvgre(inner ipv6) format, decap use layer3 as key */

    CTC_LB_HASH_SELECT_VXLAN_INNER_L2,            /**< [TM.TMM] Template T0, vxlan format, decap use layer2 as key */
    CTC_LB_HASH_SELECT_VXLAN_INNER_IPV4,          /**< [TM.TMM] Template T4, vxlan(inner ipv4) format, decap use layer3 as key */
    CTC_LB_HASH_SELECT_VXLAN_INNER_IPV6,          /**< [TM.TMM] Template T4, vxlan(inner ipv6) format, decap use layer3 as key */

    CTC_LB_HASH_SELECT_MPLS,                      /**< [TM.TMM] Template T3, mpls format, use mpls as key */
    CTC_LB_HASH_SELECT_MPLS_INNER_IPV4,           /**< [TM.TMM] Template T3, mpls(inner ipv4) format, use mpls as key */
    CTC_LB_HASH_SELECT_MPLS_INNER_IPV6,           /**< [TM.TMM] Template T3, mpls(inner ipv6) format, use mpls as key */
    CTC_LB_HASH_SELECT_MPLS_VPWS_RAW,             /**< [TM.TMM] Template T3, mpls(vpws) format, enable CTC_LB_HASH_CONTROL_VPWS_USE_INNER,
                                                          but not set CTC_GLOBAL_VPWS_SNOOPING_PARSER, use mpls as key */
    CTC_LB_HASH_SELECT_MPLS_L2VPN_INNER_L2,       /**< [TM.TMM] Template T0, mpls(l2vpn) format, decap use layer2 as key */
    CTC_LB_HASH_SELECT_MPLS_L2VPN_INNER_IPV4,     /**< [TM.TMM] Template T4, mpls(l2vpn inner ipv4) format, decap use layer3 as key */
    CTC_LB_HASH_SELECT_MPLS_L2VPN_INNER_IPV6,     /**< [TM.TMM] Template T4, mpls(l2vpn inner ipv6) format, decap use layer3 as key */
    CTC_LB_HASH_SELECT_MPLS_L3VPN_INNER_IPV4,     /**< [TM.TMM] Template T4, mpls(l3vpn inner ipv4) format, decap use layer3 as key */
    CTC_LB_HASH_SELECT_MPLS_L3VPN_INNER_IPV6,     /**< [TM.TMM] Template T4, mpls(l3vpn inner ipv6) format, decap use layer3 as key */

    CTC_LB_HASH_SELECT_TRILL_OUTER_L2_ONLY,       /**< [TM.TMM] Template T0, trill format, use layer2 as key */
    CTC_LB_HASH_SELECT_TRILL,                     /**< [TM.TMM] Template T1, trill format, use trill as key */
    CTC_LB_HASH_SELECT_TRILL_INNER_L2,            /**< [TM.TMM] Template T1, trill(inner l2) format, use trill as key */
    CTC_LB_HASH_SELECT_TRILL_INNER_IPV4,          /**< [TM.TMM] Template T1, trill(inner ipv4) format, use trill as key */
    CTC_LB_HASH_SELECT_TRILL_INNER_IPV6,          /**< [TM.TMM] Template T1, trill(inner ipv6) format, use trill as key */
    CTC_LB_HASH_SELECT_TRILL_DECAP_INNER_L2,      /**< [TM.TMM] Template T0, trill(inner l2) format, decap use layer2 as key */
    CTC_LB_HASH_SELECT_TRILL_DECAP_INNER_IPV4,    /**< [TM.TMM] Template T4, trill(inner ipv4) format, decap use layer3 as key */
    CTC_LB_HASH_SELECT_TRILL_DECAP_INNER_IPV6,    /**< [TM.TMM] Template T4, trill(inner ipv6) format, decap use layer3 as key */

    CTC_LB_HASH_SELECT_FCOE,                      /**< [TM.TMM] Template T2, fcoe format, use fcoe as key */

    CTC_LB_HASH_SELECT_FLEX_TNL_INNER_L2,         /**< [TM.TMM] Template T0, flexiable tunnel format, decap use layer2 as key, need CTC_LB_HASH_CONTROL_L2VPN_USE_INNER_L2 */
    CTC_LB_HASH_SELECT_FLEX_TNL_INNER_IPV4,       /**< [TM.TMM] Template T4, flexiable tunnel(inner ipv4) format, decap use layer3 as key */
    CTC_LB_HASH_SELECT_FLEX_TNL_INNER_IPV6,       /**< [TM.TMM] Template T4, flexiable tunnel(inner ipv6) format, decap use layer3 as key */

    CTC_LB_HASH_SELECT_UDF,                       /**< [TM.TMM] Template T6, used for scl udf select bitmap */
    CTC_LB_HASH_SELECT_MAX
};
typedef enum ctc_lb_hash_select_e ctc_lb_hash_select_t;


enum ctc_lb_hash_control_e
{
    CTC_LB_HASH_CONTROL_L2_ONLY,                    /**< [TM.TMM] only use CTC_HASH_SELECT_L2 as hash key select */
    CTC_LB_HASH_CONTROL_DISABLE_IPV4,               /**< [TM.TMM] disable ipv4 */
    CTC_LB_HASH_CONTROL_DISABLE_IPV6,               /**< [TM.TMM] disable ipv6 */
    CTC_LB_HASH_CONTROL_DISABLE_MPLS,               /**< [TM.TMM] disable mpls */
    CTC_LB_HASH_CONTROL_DISABLE_FCOE,               /**< [TM.TMM] disable fcoe */
    CTC_LB_HASH_CONTROL_DISABLE_TRILL,              /**< [TM.TMM] disable trill. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_IPV4_IN4,    /**< [TM.TMM] disable ipv4 tunnel which belongs to ipv4 message. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_IPV6_IN4,    /**< [TM.TMM] disable ipv6 tunnel which belongs to ipv4 message. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_GRE_IN4,     /**< [TM.TMM] disable gre tunnel which belongs to ipv4 message. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_NVGRE_IN4,   /**< [TM.TMM] disable nvgre tunnel which belongs to ipv4 message. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_VXLAN_IN4,   /**< [TM.TMM] disable vxlan tunnel which belongs to ipv4 message. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_IPV4_IN6,    /**< [TM.TMM] disable ipv4 tunnel which belongs to ipv6 message. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_IPV6_IN6,    /**< [TM.TMM] disable ipv6 tunnel which belongs to ip6 message. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_GRE_IN6,     /**< [TM.TMM] disable gre tunnel which belongs to ipv6 message. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_NVGRE_IN6,   /**< [TM.TMM] disable nvgre tunnel which belongs to ipv6 message. */
    CTC_LB_HASH_CONTROL_DISABLE_TUNNEL_VXLAN_IN6,   /**< [TM.TMM] disable vxlan tunnel which belongs to ipv6 message. */
    CTC_LB_HASH_CONTROL_MPLS_EXCLUDE_RSV,           /**< [TM.TMM] no care reserve label (0-15) */
    CTC_LB_HASH_CONTROL_IPV6_ADDR_COLLAPSE,         /**< [TM.TMM] use ipv6 address compress mode. */
    CTC_LB_HASH_CONTROL_IPV6_USE_FLOW_LABEL,        /**< [TM.TMM] use ipv6 flow label . */
    CTC_LB_HASH_CONTROL_NVGRE_AWARE,                /**< [TM.TMM] nvgre aware */
    CTC_LB_HASH_CONTROL_FCOE_SYMMETRIC_EN,          /**< [TM.TMM] enable fcoe symmetric hash. */
    CTC_LB_HASH_CONTROL_UDF_SELECT_MODE,            /**< [TM.TMM] select udf bits of 128bits,MODE 0:0-31, 1:32-63, 2: 64-95, 3:96-127*/
    CTC_LB_HASH_CONTROL_HASH_TYPE_UDF_DATA_BYTE_MASK, /**< [TM.TMM] mask udf-data by byte for generating lb-hash, support select id <1-7> which use as profile id for scl module*/
    CTC_LB_HASH_CONTROL_USE_MAPPED_VLAN,            /**< [TM.TMM] select mapped vlan (QinQ/vlanClass/ProtocolVlan/...) */
    CTC_LB_HASH_CONTROL_IPV4_SYMMETRIC_EN,          /**< [TM.TMM] enable ipv4 symmetric hash. */
    CTC_LB_HASH_CONTROL_IPV6_SYMMETRIC_EN,          /**< [TM.TMM] enable ipv6 symmetric hash. */
    CTC_LB_HASH_CONTROL_L2VPN_USE_INNER_L2,         /**< [TM.TMM] enable l2vpn use l2 else ipv4 or ipv6. */
    CTC_LB_HASH_CONTROL_VPWS_USE_INNER,             /**< [TM.TMM] force vpws use inner do hash. */
    CTC_LB_HASH_CONTROL_TRILL_DECAP_USE_INNER_L2,   /**< [TM.TMM] enable trill decap use l2 else ipv4 or ipv6. */
    CTC_LB_HASH_CONTROL_TRILL_TRANSMIT_MODE,        /**< [TM.TMM] select trill transmit key select mode.
                                                            mode 0: select CTC_LB_HASH_SELECT_TRILL_OUTER_L2_ONLY
                                                            mode 1: need port enable snoopParser, select CTC_LB_HASH_SELECT_TRILL_INNER_L2
                                                            mode 2: need port enable snoopParser, select CTC_LB_HASH_SELECT_TRILL_INNER_IPV4/6,CTC_LB_HASH_SELECT_TRILL_INNER_L2
                                                            mode 3: select CTC_LB_HASH_SELECT_TRILL */
    CTC_LB_HASH_CONTROL_MPLS_ENTROPY_EN,            /**< [TM] use mpls entropy label to hash key*/
    CTC_LB_HASH_CONTROL_MPLS_LABEL2_EN,             /**< [TM.TMM] use mpls label2 to hash key, incompatible with CTC_LB_HASH_CONTROL_MPLS_TRANSMIT_MODE*/

    CTC_LB_HASH_CONTROL_VXLAN_USE_INNER_L2,         /**< [TM.TMM] vxlan tunnel use l2 else ipv4 or ipv6. */
    CTC_LB_HASH_CONTROL_NVGRE_USE_INNER_L2,         /**< [TM.TMM] nvgre tunnel use l2 else ipv4 or ipv6. */
    CTC_LB_HASH_CONTROL_FLEX_TNL_USE_INNER_L2,      /**< [TM.TMM] enable flexiable tunnel use l2 else ipv4 or ipv6. */
    CTC_LB_HASH_CONTROL_HASH_SEED,                  /**< [TM.TMM] user defined hash key*/
    CTC_LB_HASH_CONTROL_HASH_TYPE_A,                /**< [TM.TMM] hash poly A, refer to ctc_lb_hash_type_t*/
    CTC_LB_HASH_CONTROL_HASH_TYPE_B,                /**< [TM.TMM] hash poly B, refer to ctc_lb_hash_type_t*/
    CTC_LB_HASH_CONTROL_HASH_SEED_USE_UDF,          /**< [TMM] UDF hash key,0:disable,1:enable*/
    CTC_LB_HASH_CONTROL_HASH_TYPE_UDF_DATA_BIT_MASK, /**< [TMM] mask udf-data by bit for generating lb-hash, support select id <1-7> which use as profile id for scl module*/
    
    CTC_LB_HASH_CONTROL_MAX
};
typedef enum ctc_lb_hash_control_e ctc_lb_hash_control_t;

enum ctc_lb_hash_config_type_e
{
    CTC_LB_HASH_CFG_HASH_SELECT,        /**< [TM.TMM] select hash_select*/
    CTC_LB_HASH_CFG_HASH_CONTROL        /**< [TM.TMM] select hash_control*/

};
typedef enum ctc_lb_hash_config_type_e ctc_lb_hash_config_type_t;

struct ctc_lb_hash_config_s
{
    uint8 sel_id;       /**< [TM.TMM] selector id <0-3> , TMM:<0-7>; for CTC_LB_HASH_SELECT_UDF, 0-3bits means udf profile id <1-7> from scl module, 4-7bits means selector id.
                                         for CTC_LB_HASH_CONTROL_HASH_TYPE_UDF_DATA_BYTE_MASK / CTC_LB_HASH_CONTROL_HASH_TYPE_UDF_DATA_BIT_MASK means udf profile id <1-7> from scl module*/
    uint8 cfg_type;     /**< [TM.TMM] configure type, refer to ctc_lb_hash_config_type_t*/
    uint8 hash_select;  /**< [TM.TMM] configure select, refer to  ctc_lb_hash_select_t*/
    uint8 hash_control; /**< [TM.TMM] configure control, refer to  ctc_lb_hash_control_t*/
    uint32 value;       /**< [TM.TMM] value*/
    uint8 udf_mask[CTC_LB_HASH_UDF_BYTE_NUM];   /**< [TMM] udf bit mask*/
};
typedef struct ctc_lb_hash_config_s ctc_lb_hash_config_t;

enum ctc_lb_hash_udf_sel_mode_e
{
    CTC_LB_HASH_UDF_SEL_MODE0,    /**< [TM.TMM] select bits 0~31   of 128 UDF bits, Outer and Inner use same UDF select*/
    CTC_LB_HASH_UDF_SEL_MODE1,    /**< [TM.TMM] select bits 32-63  of 128 UDF bits, Outer and Inner use same UDF select*/
    CTC_LB_HASH_UDF_SEL_MODE2,    /**< [TM.TMM] select bits 64-95  of 128 UDF bits, Outer and Inner use same UDF select*/
    CTC_LB_HASH_UDF_SEL_MODE3,    /**< [TM.TMM] select bits 96-127 of 128 UDF bits, Outer and Inner use same UDF select*/
    CTC_LB_HASH_UDF_SEL_MODE4,    /**< [TM] select bits 0~31   of 128 UDF bits, Outer and Inner use different UDF select*/
    CTC_LB_HASH_UDF_SEL_MODE5,    /**< [TM] select bits 32-63  of 128 UDF bits, Outer and Inner use different UDF select*/
    CTC_LB_HASH_UDF_SEL_MODE6,    /**< [TM] select bits 64-95  of 128 UDF bits, Outer and Inner use different UDF select*/
    CTC_LB_HASH_UDF_SEL_MODE7,    /**< [TM] select bits 96-127 of 128 UDF bits, Outer and Inner use different UDF select*/
    CTC_LB_HASH_UDF_SEL_MODE8,    /**< [TM.TMM] select bits 0-15 & 48-63 of 128 UDF bits, Outer and Inner use different UDF select*/
    CTC_LB_HASH_UDF_SEL_MAX_MODE
};
typedef enum ctc_lb_hash_udf_sel_mode_e ctc_lb_hash_udf_sel_mode_t;

#ifdef __cplusplus
}
#endif

#endif

